def return_trajectory(speed, angle):
radians = math.radians(angle)
x_velocity = speed * math.cos(radians)
y_velocity = speed * math.sin(radians)
return (x_velocity, y_velocity)
stage.set_background_color("black")
amount = 10
speed = 5
color_list = ["purple", "yellow", "red"]
stage.disable_all_walls()
def click():
x = stage.click_x()
y = stage.click_y()
particle_list = []
for color in color_list:
for counter in range(amount):
sprite = codesters.Circle(x, y, 10, color)
particle_list.append(sprite)
sprite.pen_down()
angle = 0
for count, p in enumerate(particle_list):
count += 1
speed_values = return_trajectory(speed, angle)
p.set_x_speed(speed_values[0])
p.set_y_speed(speed_values[1])
angle += 360/amount
if count % amount == 0:
stage.wait(.1)
stage.wait(0.5)
for p in particle_list:
p.clear()
stage.remove_sprite(p)
# add other actions...
stage.event_click(click)
stage.set_gravity(3)
stage.wait(5)
stage.set_gravity(0)
stage.event_click(None)
question1 = MCQ(1,"","","","","","", "row")
question1.set_prompt(" 1) What line of code is NOT in the event?")
question1.set_choice_A('stage.set_background_color("black")')
question1.set_choice_B("particle_list = []")
question1.set_choice_C("stage.wait(.1)")
question1.set_choice_D("angle = 0")
question1.set_correct("A")
question2 = MCQ(2,"","","","","","", "row")
question2.set_prompt("2) What line of code creates a list?")
question2.set_choice_A('for color in color_list:')
question2.set_choice_B("for p in particle_list:")
question2.set_choice_C('particle_list.append(sprite)')
question2.set_choice_D('color_list = ["purple", "yellow", "red"]')
question2.set_correct("D")
question3 = MCQ(3,"","","","","","", "row")
question3.set_prompt("3) Why would a programmer use a loop?")
question3.set_choice_A("to repeat commands whenever the user clicks the stage")
question3.set_choice_B("to repeat commands a specific number of times")
question3.set_choice_C("to store information to use again later")
question3.set_choice_D("to end a program")
question3.set_correct("B")
repeat_test = True
stop_test = False
def test_script():
global repeat_test
global stop_test
try:
tval1 = question1.correct
except:
tval1 = "DNE"
try:
tval2 = question2.correct
except:
tval2 = "DNE"
try:
tval3 = question3.correct
except:
tval3 = "DNE"
t1 = TestObjective()
t1.add_success(tval1 == True, " ")
t1.add_failure(tval1 == False, "Q1 wrong")
t1.add_failure(tval1 == "DNE", " ")
t2 = TestObjective()
t2.add_success(tval2 == True, " ")
t2.add_failure(tval2 == False, "Q2 wrong")
t2.add_failure(tval2 == "DNE", " ")
t3 = TestObjective()
t3.add_success(tval3 == True, " ")
t3.add_failure(tval3 == False, "Q3 wrong")
t3.add_failure(tval3 == "DNE", " ")
tester = TestManager()
tester.add_test_list([t1, t2, t3])
tester.run_tests()
#tester.display_first_feedback()
if repeat_test == False:
stop_test = True
test_counter = 0
def repeat_tests():
global stop_test
global test_counter
if stop_test == False:
test_script()
if test_counter >= 100:
stop_test = True
stage.event_interval(repeat_tests, .2)